package com.example.demo.web.controller;

import com.example.demo.web.entity.Barry;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * Created by Hawkins on 2018/4/10.
 */
@RestController
@EnableAutoConfiguration
public class IndexController {
    //    int i = 1;
    AtomicInteger atomicInteger = new AtomicInteger();

    @RequestMapping("/index")
    public String index() {
        System.err.println("进入IndexController12345678");
        return "Hello world,barry hawkins12345678!";
    }

    /**
     * @author wangsl
     * @date 2020/6/20 15:51
     * Description: 使用jmeter测试线程并发请求的影响
     */
    @RequestMapping("/increse")
    public String increse() {
//        int i = 1;
        System.err.println(Thread.currentThread().getName() + ": " + atomicInteger.incrementAndGet());
//        System.err.println("n："+ i);
//        int res = i;
        return  ""+atomicInteger.get();
    }

    /**
     * @param
     * @return com.example.demo.web.entity.Barry
     * @author wsl
     * @date 2018/6/19 21:08
     * @desc springboot使用的json解析框架是jackson
     */
    @RequestMapping("/getBarryPojo")
    public Barry getBarry() {
        Barry barry = new Barry();
        barry.setId(0xa3);
        barry.setName("hawkins");
        barry.setCreateDate(new Date());
        barry.setRemark("Hello,巴里..");

        return barry;
    }

    /**
     * @param
     * @return com.example.demo.web.entity.Barry
     * @author wsl
     * @date 2018/6/19 23:18
     * @desc 使用spring-boot-devtools插件热部署的作用
     * 1.当修改方法返回值,能够热部署
     * 2.当创建一个新方法时,能够热部署
     * 3.当创建一个新类时,能够热部署
     */
    @RequestMapping("/getBarryPojo2")
    public Barry getBarry2() {
        Barry barry = new Barry();
        barry.setId(0xcd);
        barry.setName("jsck");
        barry.setCreateDate(new Date());
        barry.setRemark("Hello,jsck lsift..");

        return barry;
    }
}
